import React, { Component } from "react";
import NewsLi from "./NewsLi.js";
import {  NavLink } from 'react-router-dom';

class News extends Component {
    constructor(props, context) {
      super(props)
      this.state = {
          data: []
      }
    }
  

  getCate(){
      fetch("/api/news/list",{
        method: "POST"
      }).then(res=>{
          return res.json();
        }).then((data) => {
            this.setState({
              data:data
            })
      })
    }
    componentDidMount(){
      debugger;
      this.getCate();
  }
    
  render() {
    console.log(this.state.data.rows instanceof Array)
    return (
      <content className="feed-list-container">
        <div
          className="beta-front-page-header hidden-xs"
          style={{ marginTop: "1%", marginBottom: "1%" }}
        >
          <b className="pantry-brown-title pantry-brown-title-pc">热点资讯</b>
          <NavLink to="/list" className="aaa"> more  </NavLink>
        </div>
        <ul>
          <div id="listul" className="list_content" data-pull-fresh="1">
          
             
          {this.state.data.rows && this.state.data.rows.map(
            (item,index)=>{
              return index<=3 ? <NewsLi data={item} key={index}/> : ""
            }
          ) }
            
          </div>
        </ul>
      </content>
    );
  }
}

export default News;
